![]() ![]() |
Q: What are the Mac OS X system specific OpenGL Interfaces? A: Apple currently provides 4 basic interfaces to OpenGL: CGL, AGL, NSGL, and GLUT. These APIs perform the required tasks of selecting a pixel format, creating a context for OpenGL state and finally attaching to an OS-specific drawable which selects a renderer and creates the buffers necessary for OpenGL drawing. All of these APIs also provide for buffer swaps and the ability to set context parameters and options. The 4 APIs are as follows: CGL: CGL or Core OpenGL is the lowest accessible interface API for OpenGL. It knows nothing about windowing systems but can be used directly to find both renderer information and as a full screen or off screen interface. It is accessible from both Cocoa and Carbon and is what both NSGL and AGL are built on. A complete Pbuffer interface is also provided. Functionality is provided in via the OpenGL framework and applications can include the OpenGL.h header to access CGL's functionality. Developers can see an example of using CGL with Carbon in the Carbon CGL code sample. AGL:
AGL is Apple's interface to OpenGL for Carbon applications. It can be used by both Mach-O and CFM binaries. AGL supports both windowed and full screen drawables the former by using a NSOpenGL:
Cocoa provides three classes which can be used to interface with OpenGL: NSOpenGLPixelFormat, NSOpenGLContext and NSOpenGLView. Many applications will just choose to subclass NSOpenGLView and will not need to directly subclass NSOpenGLPixelFormat nor NSOpenGLContext. NSOpenGLView is a subclass of NSView and has the expected facilities to display OpenGL content in a view. The methods declarations are found in the NSOpenGLView.h header file within the AppKit framework. Also in the AppKit framework, is the NSOpenGL.h header which provides the declarations for both NSOpenGLContext and NSOpenGLPixelFormat. These two classes provide, along with NSView, the building blocks for NSOpenGLView. Applications desiring custom context handling or more flexibility can subclass NSView, attaching their NSOpenGLContext directly to an NSView subclass. NSOpenGLContext also provides support for render to texture functionality with the GLUT: GLUT stands for GL Utility Toolkit. It is a multi-platform API that provides source level code compatibility and provides both the windowing interface and event handling. It is implemented on most UNIX platforms, Linux and Windows. As such, it provides the ability for code to be reused across multiple hardware platforms but suffers from a rather vanilla set of UI elements and event handling options. It is useful for applications that require this level of code reuse and do not require a sophisticated user interface. One strength of the GLUT API is the large amount of available sample code. Of the Apple sample code, a good place to start with GLUT is the Basic GLUT sample. [Jun 19, 2003] |
Developer Documentation | Technical Notes | Development Kits | Sample Code |